package com.example.demo.controller;

import com.example.demo.util.SessionUtil;
import com.example.demo.util.ShiroUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpSession;


/**
 * @yucs 8/23
 */
@Controller
public class MyController {

    @RequestMapping(value = {"/", "/index"},method = RequestMethod.GET)
    public String toIndex(Model model) {
        return "index";
    }

    @RequestMapping({"/admin/user_manage"})
    public String toUserManage(){
        return "user_manage";
    }


    @RequestMapping({"/admin/user_update"})
    public String toUserUpdate(){
        return "user_update";
    }

    @RequestMapping({"/main"})
    public String toMain(){
        return "main";
    }

    //测试menu_manage页面
    @RequestMapping({"/admin/menu_manage"})
    public String toMenuManage(){
        return "menu_manage";
    }

    /**
     * @yucs 2021/8/26
     * 借此测试order的函数，和orderTable的页面
     * @return
     */
    @RequestMapping("/order/orderTable")
    public String toOrderTable(){
        return "order/orderTable";
    }
    @RequestMapping("/order/orderDetail")
    public String toOrderDetail(){
        return "order/orderDetail";
    }


    @RequestMapping("/test")
    public String testUtil(HttpSession httpSession){
        String role = SessionUtil.getRole(httpSession);
//        Long role = ShiroUtils.getId();
        System.out.println("当前登录用户为: " + role);
        return  "index";
    }

}
